<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sf " uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="s " uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<title>编辑合同</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<%@ include file="/WEB-INF/common.jsp"%>

<link href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${path }/resources/css/animate.css" rel="stylesheet">
<link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">

<!--dataTables css样式-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/jquery.dataTables.min.css">
<!--DataTables button扩展-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/form.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/daterangepicker.css">

</head>
<style type="text/css" rel="stylesheet">
        #province {
            width:150px;
            margin-left:20px;
            display:inline-block;
        }
        #city{
            width:150px;
            margin-left:20px;
            display:inline-block;
        }
        #district{
            width:150px;
            margin-left:20px;
            display:inline-block;
        } 
</style>
<body class="gray-bg" style="">
<jsp:include page="/WEB-INF/loginCheck.jsp" />
	<div>
		<h1 style="margin-left:20px">编辑合同</h1>
	</div>
	<hr>
	<!--修改的表单  -->
	<div id="" barclass="panel-body" style="margin-top: 30px">
		<form id="defaultForm" action="${path }/contract/updateContract.htm?Id=${content1.id}" method="post" data-parsley-validate
										class="form-horizontal form-label-left"  enctype="multipart/form-data">
		<%-- 	<input type="hidden" name="id" value="${content.id }"> --%>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">项目名称：<span class="required">*</span>
				</label>
			 <div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="${content1.projectName}" name="projectName"  class="form-control col-md-7 col-xs-12">
				</div> 
			</div>
		  <div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">业主名称<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="proprietorId" class="selectpicker form-control" data-live-search="true" name="proprietorId" >
					    <c:forEach items="${proprietor}" var="proprietor" >
							<option value="${proprietor.id}"><c:out value="${proprietor.name}"/></option>
						</c:forEach>
					</select>
					<input type="hidden" id="proprietorHidden" value="${content1.proprietorId}"> 
				</div>
			</div>  
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">项目负责人：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="projectCharge" class="selectpicker form-control" data-live-search="true" name="projectCharge" >
				      <c:forEach items="${projectLeaderList}" var="projectLeaderList" >
							<option value="${projectLeaderList.id}"><c:out value="${projectLeaderList.name}"/></option>
						</c:forEach>
					</select>
					<input type="hidden" id="projectLeaderHidden" value="${content1.projectCharge}">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">所属城市<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<div id="distpicker5">
						<div class="form-group" id="province">
							<label class="sr-only" for="province">Province</label> <select
								class="form-control" id="province" name="province" ></select>
						</div>
						<div class="form-group" id="city">
							<label class="sr-only" for="city">City</label> <select
								class="form-control" id="city" name="city" ></select>
						</div>
						<div class="form-group" id="district">
							<label class="sr-only" for="district">District</label> <select
								class="form-control" id="district" name="district" ></select>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">详细地址<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="${content1.address}" name="address"  class="form-control col-md-7 col-xs-12">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">城市合伙人：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="${content1.cityPartner}" name="cityPartner" class="form-control col-md-7 col-xs-12">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">所属维保企业<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="${enterprise.name}" id="maintenanceEnterpriseId" name="maintenanceEnterpriseId" required="required" class="form-control col-md-7 col-xs-12">
				</div>
			</div>
			<%--<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">所属维保企业<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="enterpriseId" class="selectpicker form-control" data-live-search="true" name="enterprise" required="required">
					    <c:forEach items="${enterprise}" var="enterprise" >
							<option value="${enterprise.id}"><c:out value="${enterprise.name}"/></option>
						</c:forEach>
					</select>
					<input type="hidden" id="enterpriseIdHidden" value="${userBasicInfo.enterpriseId}">
				</div>
			</div> --%>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">签订日期：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<%-- <input  value="<fmt:formatDate value="${content1.signDate}" pattern="yyyy年MM月dd日" />" name="signDate" required="required" class="form-control col-md-7 col-xs-12"  maxlength="11"
					>
					 --%>
					<!-- 日历插件 -->
						<input type="date"  value="<fmt:formatDate value="${content1.signDate}" pattern="yyyy-MM-dd" />" name="signDate"  type="text" class="form-control col-md-7 col-xs-12" > 
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">结束日期：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					
					 <input type="date" value="<fmt:formatDate value="${content1.endDate}" pattern="yyyy-MM-dd" />" name="endDate" class="form-control col-md-7 col-xs-12" > 
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">合同总价人民币（万元）：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  type="number"  value="${content1.totalPrice}" name="totalPrice"  class="form-control col-md-7 col-xs-12" maxlength="11"
					>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">建筑物使用功能：<span class="required">*</span>
				</label>
				<%-- <div class="col-md-6 col-sm-6 col-xs-12">
					<select id="enterpriseId" class="selectpicker form-control" data-live-search="true" name="buildingFunction" required="required">
					    <c:forEach items="${function}" var="buildingFunction" >
							<option value="${buildingFunction.id}"><c:out value="${buildingFunction.functionName}"/></option>
						</c:forEach>
					</select>
				</div> --%>
				<div class="col-md-6 col-sm-6 col-xs-12">
			
					<select id="buildingFunction" class="selectpicker form-control" data-live-search="true" name="building"   onchange="changeF();">
					    <c:forEach items="${function}" var="function" >
							<option value="${function.functionName}"><c:out value="${function.functionName}"/></option>
						</c:forEach>
					</select>
				<input type="text" id="txt" value="${content1.buildingFunction}" name="buildingFunction" style="position:absolute; width:90%; height:90%;top:-1%;z-index:99; border:#FFF solid" />   
					
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">服务电话<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  type="number"  value="${content1.servicePhone}" name="sevicePhone"  class="form-control col-md-7 col-xs-12" maxlength="11"
				>
				</div>
			</div>
			<div class="form-group">
				
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">状态：<span class="required">*</span>
				</label>
				<label style="font-size:20px"><input value="已完成" name="status" type="radio"   style="margin-left:80px;">已完成</label>
				<label style="font-size:20px"><input value="未完成" name="status" type="radio"   style="margin-left:200px;">未完成</label>
				<input type="hidden" id="statusHidden" value="${content1.status}">
			</div>
			<!-- 上传图片 -->
			<div class="form-group">
				<label for="middle-name"
					class="control-label col-md-3 col-sm-3 col-xs-12">附件：</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					 <input type="file" name="file" accept="image/gif,image/jpeg,image/jpg,image/png" value="">
						
				</div>
			</div>
			<div class="form-group">
				<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" >
					<button type="submit" class="btn btn-success">提交</button>
					<a href="${path }/contract/showContract.htm" class="btn btn-primary" style="margin-left: 500px;">返回</a>
				</div>
			</div>
		</form>

	</div>
	
	<!-- Peity-->
	<script src="${path }/resources/js/plugins/peity/jquery.peity.min.js"></script>
	
	<!-- Bootstrap table-->
	<script src="${path }/resources/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${path }/resources/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

	<!-- 自定义js-->
	<script src="${path }/resources/js/content.js?v=1.0.0"></script>
	
	<!-- jQuery Validation plugin javascript-->
    <script src="${path }/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${path }/resources/js/plugins/validate/messages_zh.min.js"></script>
   
   	<!-- jQuery form  -->
    <script src="${path }/resources/js/jquery.form.min.js"></script>
    
    <!-- layer javascript -->
    <script src="${path }/resources/js/plugins/layer/layer.min.js"></script>
	
    <!-- 省市联动 -->
	<script src="${path }/resources/js/distpicker.data.js"></script>
	<script src="${path }/resources/js/distpicker.js"></script>
	<script src="${path }/resources/js/main.js"></script>
	 <script src="${path }/resources/js/jquery.validate.min.js"></script>
	<script type="text/javascript">
	function changeF() {  
		 document.getElementById('txt').value = document.getElementById('buildingFunction').options[document.getElementById('buildingFunction').selectedIndex].value;  
	    }   
	window.onload=function(){
		var proprietor = $("#proprietorHidden").val();//设置当前业主选中项
		$("#proprietorId").val(proprietor);
		
		var projectLeader = $("#projectLeaderHidden").val();//设置当前项目负责人选中项
		$("#projectCharge").val(projectLeader);
		
		var status = $("#statusHidden").val();
		$("input[name=status][value=" + status + "]").attr("checked", true); //设置当前状态选中项
		}
	$('#distpicker5').distpicker({
		  province: '${content1.province}',
		  city: '${content1.city}',
		  district: '${content1.district}'
		});
	</script>
	<script type="text/javascript">
	$("#defaultForm").validate({
		onsubmit:true,// 是否在提交是验证
		onfocusout:false,// 是否在获取焦点时验证
		onkeyupd :false,// 是否在敲击键盘时验证
		
		rules:{
			projectName:{
				required:true
			},
			proprietorId:{
				required:true
			},
			projectCharge:{
				required:true,
			},
			address:{
				required:true,
			},
			signDate:{
				required:true,
				
			},
			endDate:{
				required:true,
			},
			totalPrice:{
				required:true
			},
			buildingFunction:{
				required:true,
				
			},
			status:{
				required:true
			},
			sevicePhone:{
				required:true,
			},
		},
		messages:{
			projectName:{
				required:"请输入项目名称"
			},
			proprietorId:{
				required:"请输入业主名称"
			},
			projectCharge:{
				required:"请输入项目负责人"
			},
			address:{
				required:"请输入详细地址"
			},
			signDate:{
				required:"请输入签订日期"
				
			},
			endDate:{
				required:"请输入结束日期"
			},
			totalPrice:{
				required:"请输入合同总价"
			},
			buildingFunction:{
				required:"请输入建筑使用功能"
				
			},
			status:{
				required:"请选择状态"
			},
			sevicePhone:{
				required:"请输入服务电话"
			},
		},
		submitHandler:function(form){//通过之后回调
			alert("编辑成功！");
			form.submit();
		}
		
	});
	</script>
</body>
</html>